<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{


    public function checkLogin(){

        $usermodel=M('club_admins');
        $data['ca_name']=trim(I('post.ca_name'));
        $data['ca_password']=I('post.ca_password');
        $rs=$usermodel->where($data)->select();
      

        $code=I('post.verifycode');
        if(!$this->checkverify($code)) $this->error("验证码错误");
        if($rs){
            session("ca_name",$data['ca_name']);
            session("ca_name",$rs["ca_name"]);
            $this->success("登录成功",U("ClubAdmin/Master/index"));
            session("flag","ok");



        }
        else{
            $this->error("用户名或密码错误");
        }
}
  public function checkLoginOne(){

        $usermodel=M('admins');
        $data['admin_name']=trim(I('post.admin_name'));
        $data['admin_password']=I('post.admin_password');
        $rs=$usermodel->where($data)->select();
      

        $code=I('post.verifycode');
        if(!$this->checkverify($code)) $this->error("验证码错误");
        if($rs){
            session("admin_name",$data['admin_name']);
            session("admin_name",$rs["admin_name"]);
            $this->success("登录成功",U("Master/index"));
            session("flag","ok");



        }
        else{
            $this->error("用户名或密码错误");
        }


    }
    public function Login(){
        $this->display();
    } 


    public function verify(){
        ob_clean();
        $Verify=new\Think\Verify();
        $Verify->entry();
    }
    public function checkverify($code,$id=''){
        $Verify = new \Think\Verify();

        return $Verify->check($code,$id);
    } 

}